<?php
require_once('../config/auth.php');
require_once('guardUnit.cl.php');
$__CURRENT_PAGE__ = 'garde_unite';
$__TITLE__ = "liste de modification des unités de garde";
$guardUnit = new guardUnit();
$guardUnit->checkGuardUnit();
$type = empty($_GET['type']) ? '' : $_GET['type'];
$guardUnits = $guardUnit->getAllGuardUnits($type);

 require_once(dirname(__FILE__).'/../config/head.php');?>
<body>
<?php require_once(dirname(__FILE__).'/../config/menu.php'); ?>
<div class="container gardUnit">
<h1>Liste des unités de garde</h1>
  <a class="btn btn-success pull-right" href="form.php">Ajouter une unité de garde</a>

    <?php if(count($guardUnit->getSuccess()) > 0):?>
    <div class="alert alert-success">
        <strong>Génération des unités des gardes</strong> <br />
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <?php foreach($guardUnit->getSuccess() as $success): ?>
        <?php echo $success ?> <br />
        <?php endforeach?>
    </div>
    <?php endif ?>

    <?php if($guardUnit->getAlert()):?>
    <div class="alert">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <strong>Alerte! </strong><?php echo $guardUnit->getAlert() ?>
    </div>
    <?php endif ?>

    <label>Selectionner par</label>
<select name="type" id='type'>
<option value="">Tous les types</option>
<option <?php echo($type==GuardUnit::WEEK)  ? 'selected="selected"' : '' ?> value="<?php echo GuardUnit::WEEK ?>">Semaines</option>
<option <?php echo($type==GuardUnit::WEEKEND) ? 'selected="selected"' : '' ?> value="<?php echo GuardUnit::WEEKEND ?>">Weekends</option>
<option <?php echo($type==GuardUnit::NATHOLIDAY)?'selected="selected"':''?> value="<?php echo GuardUnit::NATHOLIDAY?>">Fêtes nationales</option>
<option <?php echo($type==GuardUnit::RELHOLIDAY)?'selected="selected"':''?> value="<?php echo GuardUnit::RELHOLIDAY?>">Fêtes religieuses</option>
    </select>
    <table class="table table-striped" width="500" aling="center">
        <thead>
            <th>Libellé</th><th>Date de début</th><th>Date de fin</th>
        </thead>
        <tbody>
            <?php foreach($guardUnits as $gardUn):?>
                <tr>
                    <td><?php echo $gardUn->label?></td><td><?php echo $gardUn->start_date?></td><td><?php echo $gardUn->end_date?></td>
                  <td> <?php echo "<a href='form.php?id=".$gardUn->id."'>modifier</a>" ?>
                </td>
                </tr>
            <?php endforeach ?>
        </tbody>
    </table>
</div>
</body>
</html>